home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / edit / teco.zip / LINE.C < prev    next >
C/C++ Source or Header  |  1986-07-15  |  649b  |  30 lines

  1. #include <ctype.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5. line()
  6. {
  7. #include "teco.h"
  8.  
  9.     int iter;                /* Iteration  < > count */
  10.     if (number < 1) while (1) {        /* Position back  */
  11.         if (!bufptx) return;        /*  ...all done   */
  12.         if (toascii(buffer[bufptx--]) == 13) {
  13.             if (! number++) {    /* Start new line *
  14.                 ++bufptx;
  15.                 if (toascii(buffer[bufptx+1]) == 10) {
  16.                     ++bufptx;
  17.                 }
  18.                 return;
  19.             }
  20.         }
  21.     }
  22.     if (number > 0) while (1) {        /* Position front */
  23.         if (bufptx+1 >= bufptr) return;
  24.         if (toascii(buffer[++bufptx]) == 13) {
  25.             if (toascii(buffer[bufptx+1]) == 10) ++bufptx;
  26.             if (! --number) return;
  27.         }
  28.     }
  29. }
  30.